package com.module.netty.handle.server;

import com.module.netty.NettyUtils;

import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerAdapter;

public class MessageServerHandler extends ChannelInboundHandlerAdapter{
	
	/**
	 * 在线
	 * @author chenluqiang
	 * @date 2019年3月26日 下午3:03:19 
	 *	@param ctx
	 *	@throws Exception
	 */
	@Override
	public void channelActive(ChannelHandlerContext ctx) throws Exception {
		NettyUtils.send(ctx, "Server say:who are you!");
	}
	
	@Override
	public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
		System.err.println(NettyUtils.say(msg)+"——————————");
	}



	@Override
	public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
		cause.printStackTrace();
		ctx.close();
	}
}